package userHelp

import (
	myConfig "common/config"
	myredis "common/redis"
	"time"
)

type stPdd struct {
}

var G_UserPdd stPdd

func (that *stPdd) AddUnuseChance(uid string, num int64) {
	myredis.AddUserFieldValueByInt64(uid, myConfig.G_tbl_pdd_turntable_info+"unuse_chance", num)
}

func (that *stPdd) AddUseChance(uid string, num int64) {
	myredis.AddUserFieldValueByInt64(uid, myConfig.G_tbl_pdd_turntable_info+"used_chance", num)
}

func (that *stPdd) AddAmount(uid string, num float64) {
	myredis.AddUserFieldValueByFloat64(uid, myConfig.G_tbl_pdd_turntable_info+"amount", num)
}

func (that *stPdd) SetUpdatedAt(uid string, time int64) {
	myredis.SetUserFieldValueByInt64(uid, myConfig.G_tbl_pdd_turntable_info+"updated_at", time)
}

// 登入后2小时充值赠送一次
func (that *stPdd) AddUnuseDeposit(uid string, confirmAt int64) {
	if time.Since(time.Unix(confirmAt, 0)).Hours() <= 2 {
		G_UserPdd.AddUnuseChance(uid, 1)
	}
}
